import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import { createPinia } from 'pinia'
import { getAuthToken } from '@/utils/auth'
import service from '@/utils/request'
// 启动 mock server（开发时使用）
const token = getAuthToken()
if (token) {
  service.defaults.headers.common['Authorization'] = `Bearer ${token}`
}
if (import.meta.env.DEV) {
  import('./mocks/browser').then(({ worker }) => {
    worker.start()
  })
}

const app = createApp(App)
app.use(createPinia()) // ✅ 正确使用
app.use(router)
app.mount('#app')
